#include <iostream>
#include "Log.hpp"
#include "hot.hpp"
#include "server.hpp"

void TestUtil(){
    std::string filename = "a.txt";
    std::string content = "asdasdasd";
    my_cloud::FileUtil fu(filename);
    fu.SetContent(content);
    cout << fu.FileSize() << endl;
    cout << fu.FileATime() << endl;
    cout << fu.FileMTime() << endl;
    std::string getcontent;
    fu.GetContent(getcontent);
    cout << getcontent << endl;
    fu.Compress("t.tgz");
}

void TestConfig(){
    my_cloud::Config* conf = my_cloud::Config::GetInstance();
    cout << conf->GetHotTime() << endl;
    cout << conf->GetServerPort() << endl;
    cout << conf->GetServerIp() << endl;
    cout << conf->GetDownloadPrefix() << endl;
    cout << conf->GetPackFileSuffix() << endl;
    cout << conf->GetPackDir() << endl;
    cout << conf->GetBackDir() << endl;
    cout << conf->GetBackupFile() << endl;
}

void TestData(){
    my_cloud::BackupInfo info1, info2;
    info1.NewBackupInfo("./a.txt");
    info2.NewBackupInfo("./b.txt");

    // cout << info._pack_flag << endl;
    // cout << info._atime << endl;
    // cout << info._mtime << endl;
    // cout << info._fsize << endl;
    // cout << info._pack_path << endl;
    // cout << info._real_path << endl;
    // cout << info._url << endl;
    auto data = my_cloud::DataManager::GetInstance();
    data->Insert(info1);
    cout << "----------------" << endl;
    data->Insert(info2);

}

void TestHot(){
    my_cloud::HotManager hot;
    hot.RunModule();
}

void TestService() {
	my_cloud::Server srv;
	srv.RunModule();
}

int main()
{
    std::thread thread_hot_manager(TestHot);
    std::thread thread_server_manager(TestService);
    thread_hot_manager.join();
    thread_server_manager.join();
    return 0;
}